<?php namespace Home\Controller;
use Hdphp\Controller\Controller;
/**
 * 用户控制器
 */
class UserController extends Controller
{
	protected $db;
	public function __init()
	{
		$this->db = new \Common\Model\User;
	}
	/**
	 * 登录
	 */
	public function login()
	{
		if(IS_POST)
		{			
			if(!$this->db->login())
			{
				$this->error($this->db->getError());
			}else{
				$this->success('登录成功','Index/index');
			}
		}		
		View::make();
	}
	/**
	 * 注册
	 */
	public function register()
	{	
		if(IS_POST)
		{			
			if(!$this->db->reg())
			{
				$this->error($this->db->getError());
			}else{
				$this->success('注册成功','login');
			}
		}
		View::make();
	}
}
